function Init() {

};
// ////////static methods////////////////

Init.initProjectName=function(){
	var pathname=window.location.pathname;
	var endIndex=pathname.indexOf('/',1);
	SysCfg.projectName=pathname.substring(1,endIndex);
};
Init.ideClose = function() {
	var deviceStore = Ext.data.StoreManager.lookup('devicestore');
	var pluginStore = Ext.data.StoreManager.lookup('pluginListStore');
	var serviceStore = Ext.data.StoreManager.lookup('serviceStore');
	var userStore = Ext.data.StoreManager.lookup('userStore');
	deviceStore.removeAll();
	pluginStore.removeAll();
	serviceStore.removeAll();
	userStore.removeAll();
	Ext.Array.each(EmulatorManager.emulators,
			function(value, index, emulators) {
				Ext.getCmp('emulatorContainer'
						+ value.id.substring(value.id.indexOf('r') + 1))
						.destroy();
			});
	Ext.Array.each(EmulatorManager.emulators,
			function(value, index, emulators) {
				value = null;
			});
	EmulatorManager.emulators.length = 0;
	EmulatorManager.currentEmulator = null;
	var disconnectWarning = Ext.create('HGMIDE.view.DisconnectWarning');
	Ext.Viewport.add(disconnectWarning);
	disconnectWarning.show();
};

/**
 * check the size of current screen
 */

Init.checkScreen = function() {
	SysCfg.emulatorMaxHeight = 615;
	if (screen.width == 1024 && screen.height == 768) {
		SysCfg.downLeftWidth = '30%';
		SysCfg.emulatorMaxWidth = 570;
	} else {
		SysCfg.downLeftWidth = '25%';
		SysCfg.emulatorMaxWidth = 870;
	}
};
Init.initKey = function() {
	window.document.onkeypress = function(event) {
		if (document.activeElement.type == 'number'
				|| document.activeElement.type == 'text'
				|| document.activeElement.type == 'password') {
			return;
		}
		LOGD("keyCode: "+event.keyCode);
		if (event.keyCode == 114 || event.keyCode == 82) {
			var runBtn = Ext.getCmp('runBtn');
			runBtn.fireEvent('tap', runBtn);
		} else if (event.keyCode == 98 || event.keyCode == 66) {
			var buildBtn = Ext.getCmp('buildBtn');
			buildBtn.fireEvent('tap', buildBtn);
		} else if (event.keyCode == 112 || event.keyCode == 80) {
			var packBtn = Ext.getCmp('packBtn');
			packBtn.fireEvent('tap', packBtn);
		} else if (event.keyCode == 116 || event.keyCode == 84) {
			var testBtn = Ext.getCmp('testBtn');
			testBtn.fireEvent('tap', testBtn);
		} else if (event.keyCode == 102 || event.keyCode == 70) {
			var refreshBtn = Ext.getCmp('refreshBtn');
			refreshBtn.fireEvent('tap', refreshBtn);
		} else if (event.keyCode == 108 || event.keyCode == 76) {
			var logBtn = Ext.getCmp('logBtn');
			logBtn.fireEvent('tap', logBtn);
		} else if (event.keyCode == 99 || event.keyCode == 67) {
			var rotateScreenBtn = Ext.getCmp('rotateScreenBtn');
			rotateScreenBtn.fireEvent('tap', rotateScreenBtn);
		} else if (event.keyCode == 115 || event.keyCode == 83) {
			var settingBtn = Ext.getCmp('settingBtn');
			settingBtn.fireEvent('tap', settingBtn);
		} else if (event.keyCode == 122 || event.keyCode == 90) {
			var id = EmulatorManager.currentEmulator.id;
			var idNum = id.substring(id.indexOf('r') + 1);
			var pluginSizeBtn = Ext.getCmp('pluginSideBtn' + idNum);
			pluginSizeBtn.fireEvent('tap', pluginSizeBtn);
		} else if (event.keyCode == 109 || event.keyCode == 77) {
			var id = EmulatorManager.currentEmulator.id;
			var idNum = id.substring(id.indexOf('r') + 1);
			var fullScreenBtn = Ext.getCmp('fullScreenBtn' + idNum);
			fullScreenBtn.fireEvent('tap', fullScreenBtn);
		} else if (event.keyCode == 113 || event.keyCode == 81) {
			var qrcodeBtn = Ext.getCmp('qrcodeBtn');
			qrcodeBtn.fireEvent('tap', qrcodeBtn);
		} else if (event.keyCode == 110 || event.keyCode == 78) {
			if (Ext.getCmp('addPluginPanel') == null) {
				var addPluginBtn = Ext.getCmp('addPluginBtn');
				addPluginBtn.fireEvent('tap', addPluginBtn);
			}
		}
	};
};
Init.initButtonMouseAnimation = function() {
	setTimeout(function() {
				var buildBtn = Ext.getDom('buildBtn');
				buildBtn.onmouseover = function() {
					Util.btnTipText.setWidth('58PX');
					Util.btnTipText.setHtml(I18N.build);
					Util.btnTipText.showBy(Ext.getCmp('buildBtn'));
				};
				buildBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};
				var packBtn = Ext.getDom('packBtn');
				packBtn.onmouseover = function() {
					Util.btnTipText.setWidth('58PX');
					Util.btnTipText.setHtml(I18N.pack);
					Util.btnTipText.showBy(Ext.getCmp('packBtn'));
				};
				packBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};
				var runBtn = Ext.getDom('runBtn');
				runBtn.onmousemove = function() {
					if (Util.overlay.getHidden()) {
						Util.overlay.showBy(Ext.getCmp('runBtn'));
					}
				};
				runBtn.onmouseout = function() {
					Util.inDeviceListPanel = false;
					document.onmousemove = function(e) {
						Util.hideDeviceOverlay(e);
					};
					setTimeout(function() {
								Util.hideDeviceListTimeOver = true;
								if (!Util.inDeviceListPanel) {
									document.onmousemove = null;
									Util.overlay.hide();
									Util.hideDeviceListTimeOver = false;
								}
							}, 400);
				};
				var testBtn = Ext.getDom('testBtn');
				testBtn.onmouseover = function() {
					Util.btnTipText.setWidth('90px');
					Util.btnTipText.setHtml(I18N.unit_test);
					Util.btnTipText.showBy(Ext.getCmp('testBtn'));
				};
				testBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};

				var refreshBtn = Ext.getDom('refreshBtn');
				refreshBtn.onmouseover = function() {
					Util.btnTipText.setWidth('58PX');
					Util.btnTipText.setHtml(I18N.refresh);
					Util.btnTipText.showBy(Ext.getCmp('refreshBtn'));
				};
				refreshBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};
				var logBtn = Ext.getDom('logBtn');
				logBtn.onmousemove = function() {
					if (Util.loggerChoosePanel.getHidden()) {
						Util.loggerChoosePanel.showBy(Ext.getCmp('logBtn'));
					}
				};
				logBtn.onmouseout = function() {
					Util.inLoggerChoosePanel = false;
					document.onmousemove = function(e) {
						Util.hideLoggerChoose(e);
					};
					setTimeout(function() {
								Util.hideLoggerChooseTimeOver = true;
								if (!Util.inLoggerChoosePanel) {
									document.onmousemove = null;
									Util.loggerChoosePanel.hide();
									Util.hideLoggerChooseTimeOver = false;
								}
							}, 400);
				};

				var settingBtn = Ext.getDom('settingBtn');
				settingBtn.onmouseover = function() {
					Util.btnTipText.setWidth('58PX');
					Util.btnTipText.setHtml(I18N.setting);
					Util.btnTipText.showBy(Ext.getCmp('settingBtn'));
				};
				settingBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};
				var rotateScreenBtn = Ext.getDom('rotateScreenBtn');
				rotateScreenBtn.onmouseover = function() {
					Util.btnTipText.setWidth('58PX');
					Util.btnTipText.setHtml(I18N.rotate_screen);
					Util.btnTipText.showBy(Ext.getCmp('rotateScreenBtn'));
				};
				rotateScreenBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};

				var qrcodeBtn = Ext.getDom('qrcodeBtn');
				qrcodeBtn.onmouseover = function() {
					Util.btnTipText.setWidth('120PX');
					var qrCodePanel = Ext.getCmp('qrcodePanel');
					if (qrCodePanel.getHidden()) {
						Util.btnTipText.setHtml(I18N.showQRCode);
					} else {
						Util.btnTipText.setHtml(I18N.hideQRCode);
					}
					Util.btnTipText.showBy(Ext.getCmp('qrcodeBtn'));
				};
				qrcodeBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};
				var addPluginBtn = Ext.getDom('addPluginBtn');
				addPluginBtn.onmouseover = function() {
					Util.btnTipText.setWidth('100PX');
					Util.btnTipText.setHtml(I18N.plugin_add);
					Util.btnTipText.showBy(Ext.getCmp('addPluginBtn'));
				};
				addPluginBtn.onmouseout = function() {
					Util.btnTipText.hide();
				};
			}, 500);
};
Init.initCmd = function() {
//	Ext.getCmp('qrcodeImage').setSrc('http://' + window.location.host
//			+ '/'+SysCfg.projectName+'/QRCodeGenerator');
	send(cmdFlag.CMD4IDCode + ':');
	setTimeout(function() {
				send(cmdFlag.CMD4Device + ':-L');
			}, 3000);
};
Init.initSingleTonOverLay = function() {
	if (!Util.created) {
		Util.overlay = Ext.create('HGMIDE.view.IDEDeviceListPanel');
		Util.btnTipText = Ext.create('HGMIDE.view.IDEBtnTipTextPanel');
		Util.loadingMaskPanel = Ext.create('HGMIDE.view.IDELoadingMaskPanel');
		Util.settingPanel = Ext.create('HGMIDE.view.IDESettingPanel');
		Util.sizeListPanel = Ext.create('HGMIDE.view.DeviceSizeListPanel');
		Util.errorInfoPanel = Ext.create('HGMIDE.view.ErrorInfoPanel');
		Util.loggerChoosePanel = Ext.create('HGMIDE.view.IDELoggerChoosePanel');
		Ext.getCmp('currentDevInfo').setHtml('<div class="devInfo"><p>'
				+ Util.currentDeveloper.get('name') + '</p><p>'
				+ Util.currentDeveloper.get('email') + '</p><p>'
				+ Util.currentDeveloper.get('ca') + '</p><div>');
		Util.created = true;
	}
};
Init.initUserList = function() {
	send(cmdFlag.CMD4User + cmdFlag.CMDFlagSeperator + '-L');
};
Init.initServiceList = function() {
	send(cmdFlag.CMD4Service + cmdFlag.CMDFlagSeperator + '-L');
};
Init.initPluginList = function() {
	send(cmdFlag.CMD4App + cmdFlag.CMDFlagSeperator + '-L');
};
Init.initCerList=function(){
	send(cmdFlag.CMD4Cer + cmdFlag.CMDFlagSeperator + '-L');
};
Init.getPluginPath = function() {
	send(cmdFlag.CMD4Dir + cmdFlag.CMDFlagSeperator);
};
Init.checkScreen();
Init.initPredefineSize = function() {
	Emulator.predefineWidth = SysCfg.predefineWidth;
	Emulator.predefineHeight = SysCfg.predefineHeight;
};